#!/bin/sh
#
#

function usage() {
    cat <<EOF
Usage: runlstat.sh <options>
options:
  -h: help
  -e: run with multiple mids
  -E: run with multiple rank-based stats
  -l <log set name>: log suffix name
EOF
}

MS2LSTAT=/home/cezanne/work/ms2sim/src/ms2lstat/ms2lstat
MODULE=/home/cezanne/work/ms2sim/modules/.libs/lpm_netshow41.so
LOGDIR=/home/cezanne/work/ms2sim/src/ms2lstat/logs
LOGBASE=tmp
LOGSETNAME=hanmir

while getopts e:E:l: c; do
    case $c in
	h)
	    usage
	    exit 0
	    ;;
	e)
	    args="$OPTARG"
	    opt="-e"
	    ;;
	E)
	    args="$OPTARG"
	    opt="-E"
	    ;;
	l)
	    LOGSUFFIX=$OPTARG
	    ;;
	*)
	    argerror=yes
	    usage
	    exit 1
	    ;;
    esac
done

if [ -z $opt ]; then
    $MS2LSTAT -m $MODULE -X -l$LOGBASE$dir/log -L $LOGDIR/NetShow.*.log
    exit $?
fi

for a in $args
do
    if [ $a -lt 0 ]; then
	dir=
	A=
    else
	dir=`printf %03u $a`
	A="$opt $a"
    fi
    $MS2LSTAT -m $MODULE -X -l$LOGBASE$dir/log -L $A $LOGDIR/$LOGSETNAME/NetShow.*.log
done
